﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spring.Context;
using Spring.Context.Support;
using Chinook.Facade;
using Chinook.Core.DaoInterface;
namespace Chinook.Facade.Ioc
{
   public class FacadeExposer
    {
       private IProfilerService _profilerService;
          public IProfilerService ProfilerService
       {
           get
           {
               if (_profilerService != null)
                   return _profilerService;
               IApplicationContext ctx = ContextRegistry.GetContext();
               _profilerService = (IProfilerService)ctx.GetObject("ProfilerService");

               if (_profilerService == null)
                   throw new TypeLoadException("Can not load object from container!");
               return _profilerService;
           }
       }

       private IEmployeeAppService _employeeAppService;
       public IEmployeeAppService EmployeeAppService
       {
           get
           {
               if (_employeeAppService != null)
                   return _employeeAppService;
               IApplicationContext ctx = ContextRegistry.GetContext();
               _employeeAppService = (IEmployeeAppService)ctx.GetObject("EmployeeAppService");

               if (_employeeAppService == null)
                   throw new TypeLoadException("Can not load object from container!");
               return _employeeAppService;
           }
       }
       private IEmployeeDao _employeeDao;
       public IEmployeeDao EmployeeDao
       {
           get
           {
               if (_employeeDao != null)
                   return _employeeDao;
               IApplicationContext ctx = ContextRegistry.GetContext();
               _employeeDao = (IEmployeeDao)ctx.GetObject("EmployeeDao");

               if (_employeeDao == null)
                   throw new TypeLoadException("Can not load object from container!");
               return _employeeDao;
           }
       }
    }
}
